#include <time.h>

#include "Globals.h"
#include "Game.h"
#include "Logger.h"

using namespace game_engine::utils;

void initLogging(void)
{
    // Initialize logging system
    Logger::configure("logger.config");
#if defined(_DEBUG)
    Logger::setLogLevel(Logger::DEBUG_MODE);
#else
    Logger::setLogLevel(Logger::RELEASE_MODE);
#endif
    Logger::INFO(GAME_LOG, "Initialization of logging system terminated");
}

INT32 main(INT32 argc, char** argv)
{
    // Initialize logging system
    initLogging();

    // Initialize random number generator seed
    srand(time(NULL));

	// Initialize the Game
    try
    {
        (Game::getInstance())->init(argc, argv);
    } catch (exception &e)
    {
        Logger::FATAL(GAME_LOG, string("Initialization error : ") + e.what());
        return 1;
    }

	// Application loop
    (Game::getInstance())->run();

    Logger::INFO(GAME_LOG, "End of main application loop");
}
